package com.orilore.gb.util;

import java.io.IOException;
import java.io.InputStream;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

public class MySessionFactory {
	
	
public static SqlSession  getSession() throws Exception {
	
	  SqlSession  session = null;
	  
	  
	  
	  SqlSessionFactoryBuilder  sfb = new SqlSessionFactoryBuilder();
	  
	  
	  String path = "SqlMapConfig.xml";
	  
	  
	  InputStream  inputstream = Resources.getResourceAsStream(path);
	  
	  
	  
	  SqlSessionFactory  sf = sfb.build(inputstream);
	  
	  
	  session = sf.openSession();
	  
	  
	  
	  
	  
	  
	  
	  return session;
	
	
	
	
	
}


public static void closeSession(SqlSession session) {
	
	
	  session.close();
	
	
}
	
	
	

}
